#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <error.h>
#include <unistd.h>
#include <string.h>

using namespace std;
#define BUFFERSIZE 16

int main()
{
    const char * file = "./mycp";
    //返回0则成功，返回-1则不成功
    int flag = access(file, F_OK);
    if(flag == 0)
    {
        cout << " 文件存在 " << endl;
    }
    else
    {
        cout << " 文件不存在 " << endl;
    }

    flag = access(file, X_OK);
    if(flag == 0)
    {
        cout << " 文件具备执行权限 " << endl;
    }
    else
    {
        cout << " 文件不具备执行权限 " << endl;
    }

    return 0;
}